package com.iflytek.controller;

import java.util.List;

import javax.validation.Valid;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.iflytek.bean.Admin;
import com.iflytek.bean.StockInOrder;
import com.iflytek.service.SioApproveService;
import com.iflytek.service.StockInOrderService;
import com.iflytek.vo.StockInOrderVO;
import com.iflytek.vo.StockOutOrderVO;
import com.iflytek.vo.layuiPage;

@RestController
@RequestMapping("/stockInOrder")
public class stockInOrderController {
	@Autowired
	private StockInOrderService stockInOrderService;
	
	@Autowired
	private SioApproveService approveService;
	
	//展示
	@RequiresPermissions("StockInOrder:show")
	@GetMapping("/show")
	public Object goodsShow() {

		List<StockInOrderVO> Page = stockInOrderService.selectByExample();
			
		layuiPage result = new layuiPage();
		result.setCode(0);
		result.setMsg("");
		result.setData(Page);
		return result;
	}
	
	//新增
	@RequiresPermissions("StockInOrder:add")
	@PostMapping("/add")
	public Object goodsAdd(@Valid StockInOrder StockInOrder) {
		
		stockInOrderService.insertSelective(StockInOrder);
		//stockInOrderService.insertIsApprove(StockInOrder.getOrderId());
		System.out.println(StockInOrder.getOrderId());
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		page.setData(StockInOrder);
		return page;
		
	}
	
	//删除
	@RequiresPermissions("StockInOrder:del")
	@GetMapping("/del")
	public Object goodsDelete(Integer orderId) {
		stockInOrderService.deleteByPrimaryKey(orderId);
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		return page;
	}
	
	
	//更新
	@RequiresPermissions("StockInOrder:edit")
	@PostMapping("/edit")
	public Object goodsEdit(StockInOrder stockInOrder) {
		stockInOrderService.updateByPrimaryKeySelective(stockInOrder);
		
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		page.setData(stockInOrder);
		return page;
	}
	
	
	
	
	
}
